home *** CD-ROM | disk | FTP | other *** search
- --------------------------------------------------------------------------------
- -- Weapon Switch Player
- -- Original Carnage Contest Weapon
- -- Script by DC, September 2009, www.UnrealSoftware.de
- --------------------------------------------------------------------------------
-
- -- Setup Tables
- if cc==nil then cc={} end
- cc.switchplayer={}
-
- -- Load & Prepare Ressources
- cc.switchplayer.gfx_wpn=loadgfx("weapons/switchplayer.png") -- Weapon Image
- setmidhandle(cc.switchplayer.gfx_wpn)
- cc.switchplayer.sfx_attack=loadsfx("boing.ogg")
-
-
- --------------------------------------------------------------------------------
- -- Weapon: Switch Player
- --------------------------------------------------------------------------------
-
- cc.switchplayer.id=addweapon("cc.switchplayer","Switch Player",cc.switchplayer.gfx_wpn,0) -- Add Weapon
-
- function cc.switchplayer.draw() -- Draw
- setblend(blend_alpha)
- setalpha(1)
- setcolor(255,255,255)
- setscale(0.5+math.abs(math.sin(math.rad(weapon_charge)))*0.5,0.5+math.cos(math.sin(math.rad(weapon_charge)))*0.5)
- drawimage(cc.switchplayer.gfx_wpn,getplayerx(0),getplayery(0)-30)
- -- Animation
- weapon_charge=weapon_charge+5
- if weapon_charge>=360 then weapon_charge=0 end
- -- HUD Positioning
- hudpositioning(pos_invisible)
- -- HUD Info
- hudinfo("Click a player of your team to switch!")
- end
-
- function cc.switchplayer.attack(attack) -- Attack
- if (weapon_position==1) then
- weapon_position=0
- weapon_shots=weapon_shots+1
- -- Find clicked player with collision
- switchto=0
- if collision(col3x3,weapon_x,weapon_y,0,1)==1 then
- if playercollision()~=0 then
- if getplayerhealth(playercollision())>0 and getplayerteam(playercollision())==getplayerteam(0) then
- switchto=playercollision()
- end
- end
- end
- -- Perform switching when player has been found
- if switchto~=0 and switchto~=playercurrent() then
- -- Use weapon and allow to use another one afterwards (1)
- useweapon(1)
- -- SFX
- playsound(cc.switchplayer.sfx_attack)
- -- Switch
- playerswitch(switchto)
- scroll(getplayerx(switchto),getplayery(switchto))
- end
- end
- end